package com.sunfeng.netty.atguigu.inboundhandlerandoutboundhandler;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;


/**
 * @author sunfeng
 */
public class MyServerInitializer extends ChannelInitializer<SocketChannel> {

    @Override
    protected void initChannel(SocketChannel ch) throws Exception {
        //一会下断点
        ChannelPipeline pipeline = ch.pipeline();

        //入站的handler进行解码 MyByteToLongDecoder    //解码对应的是入站
          pipeline.addLast(new MyByteToLongDecoder());

        // pipeline.addLast(new MyByteToLongDecoder2());

        /**
         * 出站的handler进行编码  编码对应的是出站
         */
        pipeline.addLast(new MyLongToByteEncoder());

        //自定义的handler 处理业务逻辑
        pipeline.addLast(new MyServerHandler());
        System.out.println("xxx");
    }
}
